#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
讯飞语音转写服务配置文件
"""

import os
from datetime import timedelta

class Config:
    """基础配置"""
    # Flask配置
    SECRET_KEY = os.environ.get('SECRET_KEY') or 'dev-secret-key-change-in-production'
    
    # 上传配置
    UPLOAD_FOLDER = 'uploads'
    MAX_CONTENT_LENGTH = 50 * 1024 * 1024  # 50MB
    
    # 允许的文件扩展名
    ALLOWED_EXTENSIONS = {'wav', 'mp3', 'm4a', 'flac'}
    
    # 讯飞开放平台配置
    XFYUN_APPID = os.environ.get('XFYUN_APPID') or 'your_appid_here'
    XFYUN_API_KEY = os.environ.get('XFYUN_API_KEY') or 'your_api_key_here'
    XFYUN_API_SECRET = os.environ.get('XFYUN_API_SECRET') or 'your_api_secret_here'
    
    # API配置
    API_TIMEOUT = 30  # 请求超时时间（秒）
    MAX_RETRY_TIMES = 3  # 最大重试次数
    
    # 日志配置
    LOG_LEVEL = 'INFO'
    LOG_FORMAT = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'

class DevelopmentConfig(Config):
    """开发环境配置"""
    DEBUG = True
    LOG_LEVEL = 'DEBUG'

class ProductionConfig(Config):
    """生产环境配置"""
    DEBUG = False
    LOG_LEVEL = 'WARNING'

class TestingConfig(Config):
    """测试环境配置"""
    TESTING = True
    DEBUG = True
    LOG_LEVEL = 'DEBUG'

# 配置映射
config = {
    'development': DevelopmentConfig,
    'production': ProductionConfig,
    'testing': TestingConfig,
    'default': DevelopmentConfig
}
